<template>
  <div class="components-container">
    <div class="header-form">
   
        <!-- <div class="layui-inline" >
            <label class="layui-form-label">逝者姓名</label>  
            <div class="layui-inline">
                <el-input  v-model="selectData.RegnameLike" placeholder="请输入逝者姓名" @keydown.enter.native="btnSearch"></el-input>
            </div>
        </div> -->
        <!-- <div class="layui-inline" >
            <label class="layui-form-label">客户姓名</label>  
            <div class="layui-inline">
                <el-input  v-model="selectData.DpousenameLike" placeholder="请输入客户姓名" @keydown.enter.native="btnSearch"></el-input>
            </div>
        </div> -->
        <!-- <el-button type="primary" @click="getData" :loading="this.$store.state.isloading">搜索</el-button>
        <el-button  @click="btnRepeat">重置</el-button> -->
    </div>
    <div style="margin-top:10px;">
      <ul class="toolList">
        <li>
          <el-button type="primary" @click="btnSearch" :loading="this.$store.state.isloading">刷新</el-button>
        </li>
        <li v-if="btnShow(item.BTNVALUE)" v-for="(item, index) in $store.state.btnListCommon" @click="operate(item.BTNVALUE)">
          <el-button type="primary" :value="item.BTNSHOWNAME" v-text="item.BTNSHOWNAME"></el-button>
        </li>
      </ul>
    </div>
    <dataTable :headList="headList" :dataList="dataList" :pageOrder="pageOrder" :infos="infos" @pageChange="pageChange" @selectRow="selectRow"></dataTable>
    <!-- <sweet-modal ref="checkout" class="dialog">
        <h3>{{title}}</h3>
          <div style="height:50px;">
            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">付款方式</label>
                <div class="layui-input-inline">
                  <el-select v-model="CHDCODNAME">
                    <el-option v-for="item in payment" :key="item.CodeValue" :label="item.CodeName" :value="item.CodeValue">
                    </el-option>
                  </el-select>
                </div>
              </div>
            </div>
          </div>
          <div class="layui-form-item btnCenter">
            <el-button @click="cancel" >取消</el-button>
            <el-button type="primary" :loading="loading" @click="submit">结账</el-button>
          </div>
       </sweet-modal> -->
    <printmodal ref="printPdf"></printmodal>
    <funeralRetailStockMain ref="dialog_yw" @refreshData="getData"></funeralRetailStockMain>
  </div>
</template>

<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";
.el-button + .el-button {
    margin-left: 0;
}
.btnCenter {
    text-align: center;
}
</style>
<script>
import sweetModal from "@/components/sweetModal";
import dataTable from "@/components/Table/DataTable";
import apiBase from "@/api/apiBase.js";
import funeralRetailStockMain from "./funeralRetailStockMain";
import { formatDate, timeStringToDate } from "@/utils/date.js";
import { manage } from "@/mixins/managePage.js";
import { DATESELECTMODE } from "@/const/const.js";
import { ORDER } from "@/const/orderConst.js";
import { PRINT } from "@/components/Pdf/PDF.js";
import printmodal from "@/components/Pdf/Print";
import informationRegistrationVue from "../jointPlatform/informationRegistration.vue";

const ADD = "新增";
const INFO = "义乌详情";
const CHANGE = '修改';
const DELETE = '删除';

export default {
    name: "arehousingManage",
    mixins: [manage],
    data() {
        return {
            DateSelectMode: DATESELECTMODE,
            //查询条件
            selectData: {
                RegbusnumEquals: null,
                // RegnameLike: null,
                DpousenameLike: null,
            },
            infos: null,
            selectDataExtend: {
                regDateValue: null
            },
            //收费信息
            chdData: {},
            //付款方式
            payment: [],
            CHDCODNAME: null,
            chlList: [],
            ishsownosubmit: null,
            hiddenColumnInfo: true,
            ischangered: null,
            ischangnb: null,
        };
    },
    methods: {
        ruku() {
            this.$refs.dialog.open("入库");
        },
        //获取收费信息
        getData() {
            let selectData = JSON.parse(JSON.stringify(this.selectData));
            let data = {
                PageIndex: this.pageOrder.currentPage,
                PageSize: this.pageOrder.pageSize,
                OrderBy: this.pageOrder.orderType,
                OrderByType: this.pageOrder.orderSort,
                Data: selectData
            };
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Depot.QueryRetailFuneralDpo,
                res => {
                    this.dataList = res.data.content.OutData;
                    this.pageOrder.totalNum = res.data.content.RecordCount;
                    this.$nextTick(function() {
                        let rows = document.getElementsByClassName("el-table__row");
                        if(this.ischangered){
                            this.dataList.forEach((item,index) => {
                                rows[index].style.color = '#606266';
                                if(item.REGCRETYPE === 'A'){
                                    rows[index].style.color = 'red';
                                }
                            });
                        };
                        if(this.ischangnb){
                            this.dataList.forEach((item,index) => {
                                rows[index].style.color = '#606266';
                                if(item.REGCRETYPE === 'A'||item.REGCRETYPE === 'C'){
                                    rows[index].style.color = '#007eff';
                                }
                                if(item.REGCRETYPE === 'D'){
                                    rows[index].style.color = 'red';
                                }
                            });
                        };
                    });
                }
            );
        },
        //获取表头
        getheaderlist() {
            let data = {};
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Column.GetRetailStockColumns,
                res => {
                    this.headList = res.data.content;
                }
            );
        },
        //功能操作
        operate(order) {
            this.order = order;
            switch (this.order) {
                case ADD:
                    this.$refs.dialog_yw.open(this.order);
                    break;
                case INFO:
                    this.$refs.dialog_yw.open(this.order, this.currentRow.REGBUSNUM,this.currentRow.DPOID);
                    break;
                case CHANGE:
                    this.$refs.dialog_yw.open(this.order, this.currentRow.REGBUSNUM,this.currentRow.DPOID);
                    break;
                case DELETE:
                    this.delete();
                    break;
                default:
            }
        },
        // 删除
        delete(){
             this.$confirm("确认是否删除该数据?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            })
                .then(callback => {
                    let data = {
                        DPOID: this.currentRow.DPOID,
                        DPOREGID: this.currentRow.DPOREGID
                    };
                    apiBase.DoService(
                        data,
                        apiBase.getApiAdress().Depot.DeleteFuneralDpo,
                        res => {
                            this.$message({
                                type: "success",
                                message: "删除成功!"
                            });
                            this.getData();
                        }
                    );
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消"
                    });
                });
        },
        //出库审核
        approvals() {
            this.$confirm("确认是否审核该物资?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            })
                .then(callback => {
                    let data = {
                        DPOID: this.currentRow.DPOID
                    };
                    apiBase.DoService(
                        data,
                        apiBase.getApiAdress().Depot.VerifyDpo,
                        res => {
                            this.$message({
                                type: "success",
                                message: "审核成功!"
                            });
                            this.getData();
                        }
                    );
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消"
                    });
                });
        },
        //出库发放
        grants() {
            this.$confirm("确认是否发放该物资?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            })
                .then(callback => {
                    let data = {
                        DPOID: this.currentRow.DPOID
                    };
                    apiBase.DoService(
                        data,
                        apiBase.getApiAdress().Depot.GrantDpo,
                        res => {
                            this.$message({
                                type: "success",
                                message: "发放成功!"
                            });
                            this.getData();
                        }
                    );
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消"
                    });
                });
        },
        //出库提交
        submission() {
            this.$confirm("确认是否提交该数据?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            })
                .then(callback => {
                    let data = {
                        DPOID: this.currentRow.DPOID
                    };
                    apiBase.DoService(
                        data,
                        apiBase.getApiAdress().Depot.SubmitDpo,
                        res => {
                            this.$message({
                                type: "success",
                                message: "提交成功!"
                            });
                            this.getData();
                        }
                    );
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消"
                    });
                });
        },
        //取消提交
        nosubmission(){
            this.$confirm("确认是否取消提交该数据?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            })
                .then(callback => {
                    let data = {
                        DPOID: this.currentRow.DPOID
                    };
                    apiBase.DoService(
                        data,
                        apiBase.getApiAdress().Depot.CancelGrantDpo,  
                        res => {
                            this.$message({
                                type: "success",
                                message: "取消成功成功!"
                            });
                            this.getData();
                        }
                    );
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消"
                    });
                });
        },
        //删除
        deletes() {
            this.$confirm("确认是否删除该数据?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            })
                .then(callback => {
                    let data = {
                        DPOID: this.currentRow.DPOID
                    };
                    apiBase.DoService(
                        data,
                        apiBase.getApiAdress().Depot.DeleteDpo,
                        res => {
                            this.getData();
                        }
                    );
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消"
                    });
                });
        },
        //取消
        cancel() {
            this.$refs.dialog.close();
        },
        GetDpoSubmitToGrant(){
            let data = {};
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Param.GetDpoSubmitToGrant,
                res => {
                    this.ishsownosubmit = res.data.content;
                }
            );
        },
        //查询条件重置
        btnRepeat() {
            this.selectData = {
                RegbusnumEquals: null,
                // RegnameLike: null,
                DpousenameLike: null
            };
            this.getData();
        },
        dataRepeat() {
            this.chdData = {};
        },
        GetIdvDetail() {
            let data = {};
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Param.GetIdvDetail,
                res => {
                    this.issendcar = res.data.content; //是否显示保存按钮
                    if (this.issendcar === "10") {
                        this.infos = "详情";
                    } else if (this.issendcar === "20") {
                        this.infos = "义乌详情";
                    }
                }
            );
        },
        //按钮显隐
        // DPOSTATUS
        btnShow(btn) {
            let status = "";
            if (this.currentRow) {
                status = this.currentRow.DPOSTATUS;
            }
            if (btn === ADD) return true;
            if (!this.currentRow) return false;
            if (btn === INFO || btn === CHANGE || btn === DELETE) return true;
        }
    },
    components: {
        sweetModal,
        dataTable,
        printmodal,
        funeralRetailStockMain
    },
    activated() {
        this.getData();
    },
    mounted() {
       
    },
    created() {
        apiBase.DoService({},apiBase.getApiAdress().Param.GetIsDataTableReddening,res => {
            this.ischangered = res.data.content; 
        });
        apiBase.DoService({},apiBase.getApiAdress().Param.GetIsCreChangeRed,res => {
            this.ischangnb = res.data.content; 
        });
        this.getheaderlist();
        this.GetDpoSubmitToGrant();
        this.GetIdvDetail();
    },
};
</script>

